package edu.zut.cs.network.merhandise.goods.service.impl;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;

import edu.zut.cs.network.merhandise.goods.dao.MerhandiseDao;
import edu.zut.cs.network.merhandise.goods.dao.impl.MerhandiseDaoImpl;
import edu.zut.cs.network.merhandise.goods.entity.Merhandise;
import edu.zut.cs.network.merhandise.goods.io.FileIO;
import edu.zut.cs.network.merhandise.goods.io.impl.FileIOImpl;
import edu.zut.cs.network.merhandise.goods.service.MerhandiseManager;

public class MerhandiseManagerImpl implements MerhandiseManager{
	protected Logger logger = LogManager.getLogger(this.getClass().getName());

	List<Merhandise> merhandisetList;
	Map<String, Merhandise> merhandiseMap;
	Map<Long, Merhandise> merhandiseIdMap;
	MerhandiseDao merhandiseDao = new MerhandiseDaoImpl();
	FileIO fileIO=new FileIOImpl();
	public void leadingIn(String fileName) throws InvalidFormatException, FileNotFoundException {
		// TODO Auto-generated method stub
		fileIO.leadingIn(fileName);
	}

	public void leadingOut() throws FileNotFoundException, IOException, SQLException {
		// TODO Auto-generated method stub
		fileIO.leadingOut();
	}

	public void create(Merhandise merhandise) {
		// TODO Auto-generated method stub
		merhandiseDao.create(merhandise);
	}

	public int remove(Merhandise merhandise) {
		// TODO Auto-generated method stub
		return merhandiseDao.remove(merhandise);
	}

	public void update(Merhandise merhandise) throws SQLException {
		// TODO Auto-generated method stub
		merhandiseDao.update(merhandise);
	}

	public Merhandise findById(Long id) {
		// TODO Auto-generated method stub
		return merhandiseDao.findById(id);
	}

	public Merhandise findByName(String name) {
		// TODO Auto-generated method stub
		return merhandiseDao.findByName(name);
	}


}
